package com.zs4sdk.entity;

import org.json.JSONException;
import org.json.JSONObject;

import com.common.library.util.Helper;

/**
 * 
 * function: 更新版本返回json类
 * 
 * @ author: aXiBa
 */
public class VersionJSONResultEntity extends BaseJSONEntity {
	
	public static final String UPDATETYPE_ALERT = "0";
	public static final String UPDATETYPE_NORMAL = "1";
	public static final String UPDATETYPE_FORCE = "2";

	private static final String COLUMN_CONTENT = "content";
	private static final String COLUMN_TITLE = "title";
	private static final String COLUMN_URL = "url";
	private static final String COLUMN_FORCEUPDATE = "forceupdate";
	private static final String COLUMN_APPVER = "appver";
	
	private String content;
	private String title;
	private String url;
	private String forceupdate;
	private String appver;
	
	/**
	 * 构造方法
	 */
	public VersionJSONResultEntity(){
		
	}
	/**
	 * 构造方法
	 * @param json
	 */
	public VersionJSONResultEntity(JSONObject json){
		this.fromJSON(json);
	}
	/**
	 * 构造方法
	 * @param jsonStr
	 */
	public VersionJSONResultEntity(String jsonStr){
		try{
			this.fromJSON(new JSONObject(jsonStr));
		}catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
	public VersionJSONResultEntity(VersionJSONResultEntity entity){

		this.content = entity.getContent();
		this.title = entity.getTitle();
		this.url = entity.getUrl();
		this.forceupdate = entity.getForceupdate();
		this.appver = entity.getAppver();
	}

	
	@Override
	public JSONObject toJSON() {
		JSONObject result = new JSONObject();
		try {
			result.put(COLUMN_CONTENT, this.content);
			result.put(COLUMN_TITLE, this.title);
			result.put(COLUMN_URL, this.url);
			result.put(COLUMN_FORCEUPDATE, this.forceupdate);
			result.put(COLUMN_APPVER, this.appver);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return result;
	}
	
	@Override
	public void fromJSON(JSONObject json) {
		if (Helper.isNotEmpty(json)){
			this.content = json.optString(COLUMN_CONTENT);
			this.title = json.optString(COLUMN_TITLE);
			this.url = json.optString(COLUMN_URL);
			this.forceupdate = json.optString(COLUMN_FORCEUPDATE);
			this.appver = json.optString(COLUMN_APPVER);
		}
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public String getForceupdate() {
		return forceupdate;
	}
	public void setForceupdate(String forceupdate) {
		this.forceupdate = forceupdate;
	}
	public String getAppver() {
		return appver;
	}
	public void setAppver(String appver) {
		this.appver = appver;
	}

	
	
	
}
